package com.woniu.service.impl;

import java.util.List;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniu.dto.PageData;
import com.woniu.entity.Customer;
import com.woniu.mapper.CustomerMapper;
import com.woniu.service.ICustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * 客户建档Service业务层处理
 * 
 * @author lisong
 * @date 2024-04-08
 */
@Service
public class CustomerServiceImpl implements ICustomerService
{
    @Autowired
    private CustomerMapper customerMapper;

    /**
     * 查询客户建档
     * 
     * @param id 客户建档主键
     * @return 客户建档
     */
    @Override
    public Customer selectCustomerById(Long id)
    {
        return customerMapper.selectCustomerById(id);
    }

    /**
     * 查询客户建档列表
     *
     * @return 客户建档
     */
    @Override
    public PageInfo<Customer> selectCustomerList(PageData<Customer> pageData) {
        PageHelper.startPage(pageData.getPageNum(), pageData.getPageSize());
        List<Customer> customerList = customerMapper.selectCustomerList(pageData.getParams());
        return new PageInfo<>(customerList);
    }

    /**
     * 新增客户建档
     * 
     * @param customer 客户建档
     * @return 结果
     */
    @Override
    public int insertCustomer(Customer customer)
    {
        return customerMapper.insertCustomer(customer);
    }

    /**
     * 修改客户建档
     * 
     * @param customer 客户建档
     * @return 结果
     */
    @Override
    public int updateCustomer(Customer customer)
    {
        return customerMapper.updateCustomer(customer);
    }

    /**
     * 批量删除客户建档
     * 
     * @param ids 需要删除的客户建档主键
     * @return 结果
     */
    @Override
    public int deleteCustomerByIds(Long[] ids)
    {
        return customerMapper.deleteCustomerByIds(ids);
    }

    /**
     * 删除客户建档信息
     * 
     * @param id 客户建档主键
     * @return 结果
     */
    @Override
    public int deleteCustomerById(Long id)
    {
        return customerMapper.deleteCustomerById(id);
    }

    @Override
    public List<Customer> queryAllCustomers() {

        return customerMapper.queryAllCustomers();
    }
}
